import axios from 'axios'
import { getUser } from '../utils/storage'
const ajax = axios.create({
  baseURL: 'http://ttapi.research.itcast.cn'
})
//  请求拦截器
ajax.interceptors.request.use(function (config) {
  const userInfo = getUser()
  if (userInfo && userInfo.token) {
    config.headers.Authorization = `Bearer ${userInfo.token}`
  }
  return config
},
function (error) {
  return Promise.reject(error)
})
export default ajax
